package com.gs.wzmanager.dao;

import com.gs.wzmanager.dao.mapper.ChannelMapper;
import com.gs.wzmanager.entity.Channel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ChannelDao {

    Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    ChannelMapper mapper;

    public List<Channel> queryAllChannel() {
        try {
            List<Channel> channels = mapper.queryAll();
            return channels;
        } catch (Exception e) {
            logger.info("queryAllChannel->{}", e.getMessage());
            return null;
        }
    }

    public boolean updateChannel(Channel channel) {
        try {
            mapper.update(channel);
            return true;
        } catch (Exception e) {
            logger.info("updateChannel->{}", e.getMessage());
            return true;
        }
    }

    public boolean addChannel(Channel channel) {
        try {
            mapper.addChannel(channel);
            return true;
        } catch (Exception e) {
            logger.info("addChannel->{}", e.getMessage());
            return false;
        }
    }
}
